<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>

     //1、扩展运算符的语法：  ...
     //2、扩展运算符的功能：展开数据、收集数据

     //展开数据：
     let arr = [1,3,5];
    // let arr2 = ['ok',99,...arr];
    let arr2 = [...arr,'ok',99];  //注意：这里是浅拷贝
     console.log(arr2);

     let obj = {usr:'李四',age:20};
     let obj2 = {uid:11,...obj}
     console.log(obj2);

     let goodsObj = {gname:'华为电脑',price:3000};
     let methodObj = {
                     fn:function(){
                        console.log('fn()方法')
                      },
                     demo(){
                        console.log('demo()方法');
                     }
                    };

    let obj3 = {
           data:{...goodsObj},
           methods:{...methodObj}
    }

    console.log(obj3);


    //收集数据：
    function  mydemo(...x) {  //收集数据
    // function  mydemo(x,y,z) {
    //     console.log(x,y,z);
       // console.log(arguments);

       console.log(x);

       //test(x[0],x[1],x[2]);
       test(...x);  //展开数据
      
    }

    function test(m,n,t){
         console.log(m,n,t,'m,n,t');
    }

    mydemo(1,2,88);


    let arr5 = [2,3,6,['ok',100]];
    let arr6 = [66,77,...arr5];   //注意：这里是浅拷贝
     arr6[5][0]= 'Hello';
    console.log(arr6,arr5);

    </script>
</head>
<body>
    
</body>
</html>